package reflect.annotations;

import java.lang.reflect.Method;

/**
 * 反射机制访问注解
 */
public class ReflectDemo10 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //Person类的sayHello方法上是否被注解@AutoRunMethod标注了?
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getDeclaredMethod("sayHello");
        if(method.isAnnotationPresent(AutoRunMethod.class)){
            System.out.println("被标注了!");
        }else{
            System.out.println("没有被标注!");
        }
    }
}
